﻿#region License
// (c) Intergen.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.
#endregion

using System;
using TextGlow.Control.Packaging;
using System.Xml.Linq;
using System.Collections.Generic;

namespace TextGlow.Control.Model
{
  public class Header : Content
  {
    public static readonly string RelationshipType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header";

    private readonly string _id;
    private readonly Document _document;
    private readonly IPackagePart _part;

    private readonly List<DocumentContent> _content = new List<DocumentContent>();

    public List<DocumentContent> Content
    {
      get { return _content; }
    } 

    public string Id
    {
      get { return _id; }
    }

    public override IPackagePart Part
    {
      get { return _part; }
    }

    public Header(string id, Document document, IPackagePart part, XElement element)
      : base(document)
    {
      if (id == null)
        throw new ArgumentNullException("id");
      if (document == null)
        throw new ArgumentNullException("document");
      if (part == null)
        throw new ArgumentNullException("part");
      if (element == null)
        throw new ArgumentNullException("element");

      _id = id;
      _document = document;
      _part = part;

      _content.AddRange(DocumentContent.Create(this, element.Elements()));
    }
  }
}